﻿/******************************************************************
 *                  Dipan.SanGuo Map Utils                        *
 *                                                                *
 * File Name: Dipan.SanGuo.Map.js                                 *
 * Written by: yangc (sheepchang@163.com)                         *
 * Important: to use this script don't                            *
 * remove these comments                                          *
 * Version 1.0 (MSIE 6.0 above,Firefox2.0,Netscape.)              *
 * Created Date: 2008-06-03                                       *
 ******************************************************************/

/* 地图相关函数 */
Dipan.SanGuo.Map =
{
    /** 
     * 地图初始化
     */
    Initialize: function()
    {   
        this.MapData = new Object();
        this.Infos = new Object();
        this.Citys = new Object();
        this.Tents = new Object();
        this.Users = new Object();
        this.Npc = new Object();
        this.NpcTent = new Object();
        this.copyright = false;
        
        this.CenterMapId = Dipan.SanGuo.Common.GetCookie("mid");    //地图中心点
        Dipan.SanGuo.Map.Query(this.CenterMapId, false);            //获取地图数据
        Dipan.SanGuo.Map.WriteNavigation();                         //导航图FLASH
        Dipan.SanGuo.Map.Move($("hot"),$("place"));                 //拖动初始
        Dipan.SanGuo.Map.GetStateStat(4);
    },
    
    /**
     * 地图页面模板
     */
    Template:
    {
        /**
         * 地图模板
         */
        Place1:["{for i in data.infos}",
              "<div class=\"u${i_index*1+1}\">",
              '{if i[0] == 1103754}',
              "	 <img id=\"img_${i_index}_${i[0]}_${i[1]}\" src=\"{if i[0] == -1}${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/test.gif{elseif}${map_pic}/comm/${i[1]}_${i[2]}_${i[3]}.gif{/if}\" />",
              '{elseif i[0] == 74405}',
              "	 <img id=\"img_${i_index}_${i[0]}_${i[1]}\" src=\"{if i[0] == -1}${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/test.gif{elseif}${map_pic}/comm/${i[1]}_${i[2]}_${i[3]}.gif{/if}\" />",
              '{elseif i[1] == 1 && i[2] == 1001}',//地块类型为1显示类型为1001的不显示图片
              " ",
              '{elseif i[5] != 0 && Dipan.SanGuo.Map.Citys[i[5]] != null && Dipan.SanGuo.Map.Citys[i[5]][4] != 0}',//20080910增加城池外观
              "	 <img id=\"img_${i_index}_${i[0]}_${i[1]}\" src=\"{if i[0] == -1}${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/test.gif{elseif}${map_pic}/new_face_${Dipan.SanGuo.Map.Citys[i[5]][4]}/${i[1]}_${i[2]}_${i[3]}.gif{/if}\" />",
              '{else}',
              "	 <img id=\"img_${i_index}_${i[0]}_${i[1]}\" src=\"{if i[0] == -1}${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/test.gif{elseif}${map_pic}/comm/${i[1]}_${i[2]}_${i[3]}.gif{/if}\" />",
              '{/if}',
              "</div>",
              "{/for}",
              
              '{if Dipan.SanGuo.Map.MapData.tents != null}',//有营寨
              '{for t in data.tents}',
              '{if t[6] == 0}',//没有使用瞒天过海计谋的营寨显示图片
              '{if data.infos[t[4]][1] >= 11 && data.infos[t[4]][1] <= 55}',
              '<div style="z-index:110;position: absolute;width: 19px; height: 38px; left: ${Dipan.SanGuo.Map.PlacePosition[t[4]][0]+35}px; top: ${Dipan.SanGuo.Map.PlacePosition[t[4]][1]+19}px;" onmousedown="return false;">',
              ' <img width="19px" height="38px" src="${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/flag.gif" onmousedown="return false;" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${t_index},2)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" onclick=\"Dipan.SanGuo.Map.ShowTents(${t_index},${t[3]});\" />',
              '</div>',
              '{else}',
              '<div style="position: absolute;width: 90px; height: 72px; left: ${Dipan.SanGuo.Map.PlacePosition[t[4]][0]}px; top: ${Dipan.SanGuo.Map.PlacePosition[t[4]][1]}px;" onmousedown="return false;">',
              ' <img width="90px" height="72px" src="${map_pic}/comm/move_1_${Dipan.SanGuo.Map.GetTentsImage(t[5])}.gif" onmousedown="return false;"  />',
              '</div>',
              '{/if}',
              '{/if}',
              '{/for}',
              
              '{/if}',
              
              '{if Dipan.SanGuo.Map.MapData.npc_tent != null}',//有地图任务
              '{for nt in data.npc_tent}',
              '<div style="position: absolute;width: 90px; height: 72px; left: ${Dipan.SanGuo.Map.PlacePosition[nt[3]][0]}px; top: ${Dipan.SanGuo.Map.PlacePosition[nt[3]][1]}px;" onmousedown="return false;">',
              ' <img width="90px" height="72px" src="${Dipan.SanGuo.Common.StaticsServer}/statics/images/npc_tent_${nt[1]}.gif" onmousedown="return false;"  />',
              '</div>',
              '{/for}',
              
              '{/if}'],
         
        /**
         * 热点模板
         */
        Hot1:['{if Dipan.SanGuo.Map.MapData.tents != null}',//有营寨

              '{for t in tents}',
              '{if infos[t[4]][1] == 1}',
              '{if t[6] == 0}',//没有使用瞒天过海计谋的营寨显示热点
              ' <area shape="poly" coords="${Dipan.SanGuo.Map.HotArea[t[4]]}" onmousedown="return false;" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${t_index},2)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" onclick=\"Dipan.SanGuo.Map.ShowTents(${t_index},${t[3]});\"  />',
              '{/if}',
              '{/if}',
              '{/for}',
              
              '{/if}',
              
              '{if Dipan.SanGuo.Map.MapData.npc_tent != null}',//地图任务
              
              '{for nt in npc_tent}',
              ' <area shape="poly" coords="${Dipan.SanGuo.Map.HotArea[nt[3]]}" onmousedown="return false;" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${nt_index},3)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" onclick=\"Dipan.SanGuo.Map.ShowNpcTent(${nt_index},${nt[2]});\"  />',
              '{/for}',
              
              '{/if}',
              
              "{for i in infos}",
              '{if i[0] == 1103754}',
              "	 <area id=\"a_${i_index}_${i[0]}_${i[1]}\" shape=\"poly\" coords=\"${Dipan.SanGuo.Map.HotArea[i_index]}\" onmousedown=\"return false;\" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${i_index},1)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" />",
              '{elseif i[0] == 74405}',
              "	 <area id=\"a_${i_index}_${i[0]}_${i[1]}\" shape=\"poly\" coords=\"${Dipan.SanGuo.Map.HotArea[i_index]}\" onmousedown=\"return false;\" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${i_index},1)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" />",
              '{elseif i[1] == 1}',
              "	 <area id=\"a_${i_index}_${i[0]}_${i[1]}\" shape=\"poly\" coords=\"${Dipan.SanGuo.Map.HotArea[i_index]}\" onmousedown=\"return false;\" />",
              '{elseif i[0] != -1}',
              "	 <area id=\"a_${i_index}_${i[0]}_${i[1]}\" shape=\"poly\" coords=\"${Dipan.SanGuo.Map.HotArea[i_index]}\" onmousedown=\"return false;\" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${i_index},1)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" />",
              '{/if}',
              "{/for}"],
              
        /**
         * 地图模板
         */
        Place2:[
              "{for i in data.infos}",
              
              "<div class=\"u${i_index*1+1}\">",
                  '{if i[1] == 1 && i[2] == 1001}',//地块类型为1显示类型为1001的不显示图片
                  " ",
                  '{elseif i[5] != 0 && Dipan.SanGuo.Map.Citys[i[5]] != null && Dipan.SanGuo.Map.Citys[i[5]][4] != 0}',//20080910增加城池外观
                  "	 <img id=\"img_${i_index}_${i[0]}_${i[1]}\" src=\"{if i[0] == -1}${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/test.gif{elseif}${map_pic}/new_face_${Dipan.SanGuo.Map.Citys[i[5]][4]}/${i[1]}_${i[2]}_${i[3]}.gif{/if}\" />",
                  '{else}',
                  "	 <img id=\"img_${i_index}_${i[0]}_${i[1]}\" src=\"{if i[0] == -1}${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/test.gif{elseif}${map_pic}/comm/${i[1]}_${i[2]}_${i[3]}.gif{/if}\" />",
                  '{/if}',
              "</div>",
              
              "{/for}",
              
              
              '{if Dipan.SanGuo.Map.MapData.tents != null}',//有营寨

              '{for t in data.tents}',
              '{if t[6] == 0}',//没有使用瞒天过海计谋的营寨显示图片
              '{if data.infos[t[4]][1] >= 11 && data.infos[t[4]][1] <= 55}',
              '<div style="z-index:110;position: absolute;width: 19px; height: 38px; left: ${Dipan.SanGuo.Map.PlacePosition[t[4]][0]+35}px; top: ${Dipan.SanGuo.Map.PlacePosition[t[4]][1]+19}px;" onmousedown="return false;">',
              ' <img width="19px" height="38px" src="${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/flag.gif" onmousedown="return false;" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${t_index},2)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" onclick=\"Dipan.SanGuo.Map.ShowTents(${t_index},${t[3]});\" />',
              '</div>',
              '{else}',
              '<div style="position: absolute;width: 90px; height: 72px; left: ${Dipan.SanGuo.Map.PlacePosition[t[4]][0]}px; top: ${Dipan.SanGuo.Map.PlacePosition[t[4]][1]}px;" onmousedown="return false;">',
              ' <img width="90px" height="72px" src="${map_pic}/comm/move_1_${Dipan.SanGuo.Map.GetTentsImage(t[5])}.gif" onmousedown="return false;"  />',
              '</div>',
              '{/if}',
              '{/if}',
              '{/for}',
              
              '{/if}',
              
              '{if Dipan.SanGuo.Map.MapData.npc_tent != null}',//有地图任务
              '{for nt in data.npc_tent}',
              '<div style="position: absolute;width: 90px; height: 72px; left: ${Dipan.SanGuo.Map.PlacePosition[nt[3]][0]}px; top: ${Dipan.SanGuo.Map.PlacePosition[nt[3]][1]}px;" onmousedown="return false;">',
              ' <img width="90px" height="72px" src="${Dipan.SanGuo.Common.StaticsServer}/statics/images/npc_tent_${nt[1]}.gif" onmousedown="return false;"  />',
              '</div>',
              '{/for}',
              
              '{/if}'],
         
        /**
         * 热点模板
         */
        Hot2:['{if Dipan.SanGuo.Map.MapData.tents != null}',//有营寨
              '{for t in tents}',
              '{if infos[t[4]][1] == 1}',
              '{if t[6] == 0}',//没有使用瞒天过海计谋的营寨显示热点
              ' <area shape="poly" coords="${Dipan.SanGuo.Map.HotArea[t[4]]}" onmousedown="return false;" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${t_index},2)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" onclick=\"Dipan.SanGuo.Map.ShowTents(${t_index},${t[3]});\"  />',
              '{/if}',
              '{/if}',
              '{/for}',
              
              '{/if}',
              
              '{if Dipan.SanGuo.Map.MapData.npc_tent != null}',//地图任务
              
              '{for nt in npc_tent}',
              ' <area shape="poly" coords="${Dipan.SanGuo.Map.HotArea[nt[3]]}" onmousedown="return false;" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${nt_index},3)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" onclick=\"Dipan.SanGuo.Map.ShowNpcTent(${nt_index},${nt[2]});\"  />',
              '{/for}',
              
              '{/if}',
              
              "{for i in infos}",
              '{if i[1] == 1}',
              "	 <area id=\"a_${i_index}_${i[0]}_${i[1]}\" shape=\"poly\" coords=\"${Dipan.SanGuo.Map.HotArea[i_index]}\" onmousedown=\"return false;\" />",
              '{elseif i[0] != -1}',
              "	 <area id=\"a_${i_index}_${i[0]}_${i[1]}\" shape=\"poly\" coords=\"${Dipan.SanGuo.Map.HotArea[i_index]}\" onmousedown=\"return false;\" onmouseover=\"Dipan.SanGuo.Map.ShowItemDetail(${i_index},1)\" onmouseout=\"Dipan.SanGuo.Map.HideItemDetail()\" />",
              '{/if}',
              "{/for}"],
        
        /**
         * 信息显示浮层
         */
        DivItemDetail:['<div class="top"><span></span></div>',
                        '<div class="s_cont">',
                        '<div class="main2">',
                        '<div class="det yellow4 font12">{if flag == 1}${Dipan.SanGuo.Map.GetPlaceInfo(infos[0],infos[1])}{elseif flag == 2}${Dipan.SanGuo.Map.GetTentInfo(infos[0],infos[1])}{elseif flag == 3}${Dipan.SanGuo.Map.GetNpcTentInfo(infos[0],infos[1])}{/if}</div>',
                        '<div class="clear"></div>',
                        '</div>',
                        '</div>',
                        '<div class="bottom"><span></span></div>'],
                        
        ShowMessage:['<div class="top">',
                    '<div class="l">',
                    '</div>',
                    '<div class="m">',
                    '</div>',
                    '<div class="r">',
                    '</div>',
                    '</div>',
                    '<div class="cont">',
                    '<div class="title" id="drag_msg" style="cursor: move;" title="拖动">',
                    '<div>',
                    '<div class="tl">',
                    '</div>',
                    '<div class="tm white_12b">',
                    '写消息</div>',
                    '<div class="tr">',
                    '</div>',
                    '</div>',
                    '<div class="close">',
                    "<a title=\"关闭\" href=\"javascript:;\" onclick=\"Dipan.SanGuo.Common.CloseDialog('_msg');return false;\">",
                    '<img border="0"  alt="" src="${Dipan.SanGuo.Common.StaticsServer}/Statics/Images/float/f_11.gif" /></a></div>',
                    '</div>',
                    '</div>',
                    '<div class="cont">',
                    '<div class="container">',
                    '<div class="float_tax_all yellow6">',
                    '<table bgcolor="#72674F" border="0" cellpadding="2" cellspacing="1" class="table_bg">',
                    '<tr class="tr yellow4">',
                    '<td class="bold" width="63">收件人：</td>',
                    '{if yn==0}',//不是群发
                    '<td><input name="name" id="name" size="55" type="text" maxlength="32" value="${uname}" /></td>',
                    '{else}',
                    '<td><input size="55" type="text" maxlength="32" value="盟内所有成员"  disabled=true/></td>',
                    '<input name="name" id="name" type="hidden" maxlength="32" value="ally" />',
                    '{/if}',
                    '</tr>',
                    '<tr class="tr yellow4">',
                    '<td class="bold" width="63">标&nbsp;&nbsp;&nbsp; 题：</td>',
                    '<td><input name="title" id="title" size="55" type="text" maxlength="120" /></td>',
                    '</tr>',
                    '<tr class="tr yellow4">',
                    '<td class="bold" width="63">内&nbsp;&nbsp;&nbsp; 容：</td>',
                    '<td>',
                    '<textarea class="messages_textarea2" name="content" id="content"></textarea></td>',
                    '</tr>',
                    '</table>',
                    '<table border="0" cellpadding="0" cellspacing="0" class="margintop textcenter" width="100%">',
                    '<tr>',
                    '<td align="center" width="39%"></td>',
                    '<td align="center" width="61%">',
                    '<a class="bun_4 but_12" href="#" onclick="Dipan.SanGuo.Map.SendMessage(); return false;">发送</a><a class="bun_4 but_12" href="#" onclick="Dipan.SanGuo.Common.CloseDialog(\'_msg\')">关闭</a></td>',
                    '</tr>',
                    '</table>',
                    '</div>',
                    '</div>',
                    '</div>',
                    '<div class="top">',
                    '<div class="bl">',
                    '</div>',
                    '<div class="bm">',
                    '</div>',
                    '<div class="br">',
                    '</div>',
                    '</div>']
    },
    
    /**
     * 获取营寨图片
     * @param {walllevel} 栏栅等级
     */
    GetTentsImage: function(walllevel)
    {
        if (walllevel >= 0 && walllevel <= 9)
            return "1";
        else if (walllevel >= 10 && walllevel <= 19)
            return "2";
        else if (walllevel >= 20)
            return "3";
    },
    
    /**
     * 热点定位
     */
    HotArea:
    [
        [899,37,944,1,989,37,945,73],
        [809,36,854,0,899,36,855,72],
        [855,72,900,36,945,72,901,108],
        [901,109,946,73,991,109,947,145],
        [720,36,765,0,810,36,766,72],
        [765,72,810,36,855,72,811,108],
        [810,108,855,72,900,108,856,144],
        [856,144,901,108,946,144,902,180],
        [900,181,945,145,990,181,946,217],
        [629,36,674,0,719,36,675,72],
        [676,72,721,36,766,72,722,108],
        [721,109,766,73,811,109,767,145],
        [767,146,812,110,857,146,813,182],
        [813,182,858,146,903,182,859,218],
        [857,218,902,182,947,218,903,254],
        [903,254,948,218,993,254,949,290],
        [539,35,584,-1,629,35,585,71],
        [584,71,629,35,674,71,630,107],
        [630,107,675,71,720,107,676,143],
        [675,143,720,107,765,143,721,179],
        [720,180,765,144,810,180,766,216],
        [766,216,811,180,856,216,812,252],
        [810,252,855,216,900,252,856,288],
        [855,288,900,252,945,288,901,324],
        [901,324,946,288,991,324,947,360],
        [450,35,495,-1,540,35,496,71],
        [494,72,539,36,584,72,540,108],
        [540,108,585,72,630,108,586,144],
        [586,144,631,108,676,144,632,180],
        [629,179,674,143,719,179,675,215],
        [674,215,719,179,764,215,720,251],
        [719,251,764,215,809,251,765,287],
        [764,287,809,251,854,287,810,323],
        [809,323,854,287,899,323,855,359],
        [855,359,900,323,945,359,901,395],
        [901,396,946,360,991,396,947,432],
        [360,35,405,-1,450,35,406,71],
        [405,71,450,35,495,71,451,107],
        [451,107,496,71,541,107,497,143],
        [495,144,540,108,585,144,541,180],
        [541,180,586,144,631,180,587,216],
        [585,215,630,179,675,215,631,251],
        [630,251,675,215,720,251,676,287],
        [674,287,719,251,764,287,720,323],
        [720,323,765,287,810,323,766,359],
        [765,360,810,324,855,360,811,396],
        [810,395,855,359,900,395,856,431],
        [854,431,899,395,944,431,900,467],
        [900,468,945,432,990,468,946,504],
        [269,33,314,-3,359,33,315,69],
        [314,70,359,34,404,70,360,106],
        [360,107,405,71,450,107,406,143],
        [405,143,450,107,495,143,451,179],
        [449,179,494,143,539,179,495,215],
        [494,215,539,179,584,215,540,251],
        [540,251,585,215,630,251,586,287],
        [585,286,630,250,675,286,631,322],
        [630,323,675,287,720,323,676,359],
        [674,358,719,322,764,358,720,394],
        [719,394,764,358,809,394,765,430],
        [765,431,810,395,855,431,811,467],
        [810,468,855,432,900,468,856,504],
        [179,34,224,-2,269,34,225,70],
        [225,70,270,34,315,70,271,106],
        [269,107,314,71,359,107,315,143],
        [314,142,359,106,404,142,360,178],
        [359,178,404,142,449,178,405,214],
        [403,215,448,179,493,215,449,251],
        [449,250,494,214,539,250,495,286],
        [494,286,539,250,584,286,540,322],
        [539,322,584,286,629,322,585,358],
        [584,358,629,322,674,358,630,394],
        [630,394,675,358,720,394,676,430],
        [675,430,720,394,765,430,721,466],
        [720,467,765,431,810,467,766,503],
        [90,36,135,0,180,36,136,72],
        [135,71,180,35,225,71,181,107],
        [180,107,225,71,270,107,226,143],
        [225,143,270,107,315,143,271,179],
        [270,179,315,143,360,179,316,215],
        [315,215,360,179,405,215,361,251],
        [359,250,404,214,449,250,405,286],
        [404,286,449,250,494,286,450,322],
        [449,322,494,286,539,322,495,358],
        [494,358,539,322,584,358,540,394],
        [539,394,584,358,629,394,585,430],
        [585,430,630,394,675,430,631,466],
        [630,466,675,430,720,466,676,502],
        [-2,35,43,-1,88,35,44,71],
        [44,71,89,35,134,71,90,107],
        [89,107,134,71,179,107,135,143],
        [134,142,179,106,224,142,180,178],
        [178,178,223,142,268,178,224,214],
        [224,214,269,178,314,214,270,250],
        [269,250,314,214,359,250,315,286],
        [314,287,359,251,404,287,360,323],
        [360,322,405,286,450,322,406,358],
        [405,358,450,322,495,358,451,394],
        [450,394,495,358,540,394,496,430],
        [495,430,540,394,585,430,541,466],
        [541,467,586,431,631,467,587,503],
        [-1,108,44,72,89,108,45,144],
        [45,144,90,108,135,144,91,180],
        [91,180,136,144,181,180,137,216],
        [136,215,181,179,226,215,182,251],
        [179,250,224,214,269,250,225,286],
        [224,286,269,250,314,286,270,322],
        [269,322,314,286,359,322,315,358],
        [314,358,359,322,404,358,360,394],
        [360,394,405,358,450,394,406,430],
        [405,430,450,394,495,430,451,466],
        [451,466,496,430,541,466,497,502],
        [-1,180,44,144,89,180,45,216],
        [44,214,89,178,134,214,90,250],
        [90,251,135,215,180,251,136,287],
        [134,286,179,250,224,286,180,322],
        [180,324,225,288,270,324,226,360],
        [225,359,270,323,315,359,271,395],
        [270,394,315,358,360,394,316,430],
        [314,430,359,394,404,430,360,466],
        [360,466,405,430,450,466,406,502],
        [-1,250,44,214,89,250,45,286],
        [45,287,90,251,135,287,91,323],
        [89,323,134,287,179,323,135,359],
        [134,358,179,322,224,358,180,394],
        [180,394,225,358,270,394,226,430],
        [224,430,269,394,314,430,270,466],
        [269,466,314,430,359,466,315,502],
        [-1,323,44,287,89,323,45,359],
        [44,358,89,322,134,358,90,394],
        [89,394,134,358,179,394,135,430],
        [134,430,179,394,224,430,180,466],
        [179,467,224,431,269,467,225,503],
        [-2,394,43,358,88,394,44,430],
        [44,430,89,394,134,430,90,466],
        [90,466,135,430,180,466,136,502],
        [-2,466,43,430,88,466,44,502]//共137块
    ],
    
    /**
     * 地块定位
     */
    PlacePosition:
    [
        [900,0],[810,0],[855,36],[900,72],[720,0],[765,36],[810,72],[855,108],[900,144],[630,0],[675,36],
        [720,72],[765,108],[810,144],[855,180],[900,216],[540,0],[585,36],[630,72],[675,108],[720,144],
        [765,180],[810,216],[855,252],[900,288],[450,0],[495,36],[540,72],[585,108],[630,144],[675,180],
        [720,216],[765,252],[810,288],[855,324],[900,360],[360,0],[405,36],[450,72],[495,108],[540,144],
        [585,180],[630,216],[675,252],[720,288],[765,324],[810,360],[855,396],[900,432],[270,0],[315,36],
        [360,72],[405,108],[450,144],[495,180],[540,216],[585,252],[630,288],[675,324],[720,360],[765,396],
        [810,432],[180,0],[225,36],[270,72],[315,108],[360,144],[405,180],[450,216],[495,252],[540,288],
        [585,324],[630,360],[675,396],[720,432],[90,0],[135,36],[180,72],[225,108],[270,144],[315,180],
        [360,216],[405,252],[450,288],[495,324],[540,360],[585,396],[630,432],[0,0],[45,36],[90,72],
        [135,108],[180,144],[225,180],[270,216],[315,252],[360,288],[405,324],[450,360],[495,396],[540,432],
        [0,72],[45,108],[90,144],[135,180],[180,216],[225,252],[270,288],[315,324],[360,360],[405,396],
        [450,432],[0,144],[45,180],[90,216],[135,252],[180,288],[225,324],[270,360],[315,396],[360,432],
        [0,216],[45,252],[90,288],[135,324],[180,360],[225,396],[270,432],[0,288],[45,324],[90,360],
        [135,396],[180,432],[0,360],[45,396],[90,432],[0,432]//共137块
    ],
    
    /**
     * 地图查询
     * @param {CenterMapId} 地图中心点
     */
    Query: function(CenterMapId,flag)
    {
        var RemoteData = new Dipan.SanGuo.Common.RemoteData()
        RemoteData.Post("/GateWay/Map.ashx?id=6", "mid=" + CenterMapId);
        RemoteData.onComplete = function(resp)
        {
            var JsonData = eval ('(' + resp + ')');
            if (JsonData.ret * 1 == 0)
            {
                //解析获取的地图数据

                Dipan.SanGuo.Map.MapData = JsonData;
                Dipan.SanGuo.Map.GetMapData();
                Dipan.SanGuo.Map.CenterMapId = JsonData.infos[68][0];
                
                try
                {
                    var data = {map_pic:Dipan.SanGuo.Common.MapPic,data:JsonData}
                    
                    if (Dipan.SanGuo.Map.copyright)
                    {
                        Dipan.SanGuo.Common.FixData(Dipan.SanGuo.Map.Template.Place1, "place", data, true);
                        Dipan.SanGuo.Common.FixData(Dipan.SanGuo.Map.Template.Hot1, "area", JsonData, true);
                    }
                    else
                    {
                        Dipan.SanGuo.Common.FixData(Dipan.SanGuo.Map.Template.Place2, "place", data, true);
                        Dipan.SanGuo.Common.FixData(Dipan.SanGuo.Map.Template.Hot2, "area", JsonData, true);
                    }
                    
                    if (flag)
                        Dipan.SanGuo.Map.NavigationShowPos();
                }
                catch (e)
                {
                    //alert(e.message);
                }
                
                //地图显示层位置复原
                $("place").style.left = "0px";
                $("place").style.top = "0px";
            }
            else
            {
                //返回不成功后到统一方法处理错误信息
                Dipan.SanGuo.Common.ResultInfo(JsonData.ret);
            }
        } 
    },
    
    /**
     * 解析地图数据
     */
    GetMapData: function()
    {
        if (Dipan.SanGuo.Map.MapData.infos != null)
        {
            //将地块信息以地块编号为索引保存到Infos中
            for (var nI = 0; nI < Dipan.SanGuo.Map.MapData.infos.length; nI ++)
            {
                Dipan.SanGuo.Map.Infos[Dipan.SanGuo.Map.MapData.infos[nI][0]] = Dipan.SanGuo.Map.MapData.infos[nI];
            }
        }
        if (Dipan.SanGuo.Map.MapData.citys != null)
        {
            //将城池信息以城池编号为索引保存到Citys中
            for (var nI = 0; nI < Dipan.SanGuo.Map.MapData.citys.length; nI ++)
            {
                Dipan.SanGuo.Map.Citys[Dipan.SanGuo.Map.MapData.citys[nI][0]] = Dipan.SanGuo.Map.MapData.citys[nI];
            }
        }
        if (Dipan.SanGuo.Map.MapData.tents != null)
        {
            //将营寨信息以营寨编号为索引保存到Tents中
            for (var nI = 0; nI < Dipan.SanGuo.Map.MapData.tents.length; nI ++)
            {
                Dipan.SanGuo.Map.Tents[Dipan.SanGuo.Map.MapData.tents[nI][0]] = Dipan.SanGuo.Map.MapData.tents[nI];
            }
        }
        if (Dipan.SanGuo.Map.MapData.users != null)
        {
            //将用户信息以用户编号为索引保存到Users中
            for (var nI = 0; nI < Dipan.SanGuo.Map.MapData.users.length; nI ++)
            {
                Dipan.SanGuo.Map.Users[Dipan.SanGuo.Map.MapData.users[nI][0]] = Dipan.SanGuo.Map.MapData.users[nI];
            }
        }
        if (Dipan.SanGuo.Map.MapData.npc != null)
        {
            //将Npc城池信息以Npc城池编号为索引保存到Npc中
            for (var nI = 0; nI < Dipan.SanGuo.Map.MapData.npc.length; nI ++)
            {
                Dipan.SanGuo.Map.Npc[Dipan.SanGuo.Map.MapData.npc[nI][0]] = Dipan.SanGuo.Map.MapData.npc[nI];
            }
        }
        if (Dipan.SanGuo.Map.MapData.npc_tent != null)
        {
            //将地图任务信息以地图任务编号为索引保存到NpcTents中
            for (var nI = 0; nI < Dipan.SanGuo.Map.MapData.npc_tent.length; nI ++)
            {
                Dipan.SanGuo.Map.NpcTent[Dipan.SanGuo.Map.MapData.npc_tent[nI][0]] = Dipan.SanGuo.Map.MapData.npc_tent[nI];
            }
        }
    },
    
    /**
     * 地图拖动
     */
    Move: function(o, p)
	{
	    o.onmousedown = function(a)
	    {
	        var l = p.style.left.substring(0,p.style.left.indexOf('px'));
            var t = p.style.top.substring(0,p.style.top.indexOf('px'));
            
            if(l == null)
            {
                l = 0;
            }
            if(t == null)
            {
                t = 0;
            }
            if(!a) a = window.event;
            var ml = a.pageX?a.pageX:a.clientX;
            var mt = a.pageY?a.pageY:a.clientY;
            var d = document;
            
            d.ondragstart = "return false;";
            d.onselectstart = "return false;";
            d.onselect = "document.selection.empty();";
            if(o.setCapture) o.setCapture(); else if(window.captureEvents) window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); 

            o.onmousemove = function(a)
            {
                Dipan.SanGuo.Map.HideItemDetail();
                o.style.cursor = "move";
                if(!a) a = window.event;
                var tx = a.pageX?a.pageX-ml:a.clientX-ml;
                var ty = a.pageY?a.pageY-mt:a.clientY-mt;
                p.style.left = l*1 + tx*1 + "px";
                p.style.top = t*1 + ty*1 + "px";
            }

            o.onmouseup = function()
            {
                if(o.releaseCapture) o.releaseCapture(); else if(window.captureEvents) window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); d.onmousemove = null; d.onmouseup = null; d.ondragstart = null; d.onselectstart = null; d.onselect = null;
                o.onmousemove = null;
                o.onmouseup = null;
                o.onmouseleave = null;
                o.style.cursor = "default";
                var temp = (typeof a.target != "undefined")?a.target:a.srcElement;
                
                var nNowX = Math.abs(p.style.left.substring(0,p.style.left.indexOf('px')));
                var nNowY = Math.abs(p.style.top.substring(0,p.style.top.indexOf('px')));
                if (nNowX == null)
                {
                    nNowX = 0;
                }
                if (nNowY == null)
                {
                    nNowY = 0;
                }
                var bIsRightMosue = false;
                if (window.event)
                {
                    if (a.button == 2)
                    {
                        bIsRightMosue = true;
                    }
                }
                else
                {
                    if (a.button == 2)
                    {
                        bIsRightMosue = true;
                    }
                }
                //单击事件
                if (nNowX < 5 && nNowY < 5)
                {
                    if (temp != null && temp.id != null)
                    {
                        var aPlace = temp.id.split('_');
                        
                        if (Dipan.SanGuo.Map.copyright)
                        {
                            if (aPlace[2] == "1103754") {alert("哇拷，GM的地盘你也敢占哇...");return;}
                            if (aPlace[2] == "74405") {alert("哇拷，GM的地盘你也敢占哇...");return;}
                        }
                        
                        switch (aPlace[3] * 1)
                        {
                            case 1://空地
                                {
                                    var Loader = new Dipan.SanGuo.Common.Loader();
        
                                    Loader.onsuccess = function()
                                    {
                                        Dipan.SanGuo.Place.place(aPlace[2]);
                                    }
                                    
                                    Loader.js(Dipan.SanGuo.Common.StaticsServer + "/Statics/JavaScripts/Dipan.SanGuo.Place.js", true);
                                }
                                break;
                            case 11:
                            case 12:
                            case 13:
                            case 14:
                            case 15:
                            case 16:
                            case 17:
                            case 18:
                            case 19:
                            case 20:
                            case 21:
                            case 22:
                            case 23:
                            case 24:
                            case 25:
                            case 26:
                            case 27:
                            case 28:
                            case 29:
                            case 30:
                            case 31:
                            case 32:
                            case 33:
                            case 34:
                            case 35:
                            case 36:
                            case 37:
                            case 38:
                            case 39:
                            case 40:
                            case 41:
                            case 42:
                            case 43:
                            case 44:
                            case 45:
                            case 46:
                            case 47:
                            case 48:
                            case 49:
                            case 50:
                            case 51:
                            case 52:
                            case 53:
                            case 54:
                            case 55://绿洲
                                {
                                    var Loader = new Dipan.SanGuo.Common.Loader();
        
                                    Loader.onsuccess = function()
                                    {
                                        Dipan.SanGuo.Oasis.oasis(aPlace[2]);
                                    }
                                    
                                    Loader.js(Dipan.SanGuo.Common.StaticsServer + "/Statics/JavaScripts/Dipan.SanGuo.Oasis.js", true);
                                }
                                break;
                            case 62:
                            case 63:
                            case 64:
                            case 65://NPC城池
                                {
                                    var Loader = new Dipan.SanGuo.Common.Loader();
        
                                    Loader.onsuccess = function()
                                    {
                                        Dipan.SanGuo.NpcCity.npccity(aPlace[2]);
                                    }
                                
                                    Loader.js(Dipan.SanGuo.Common.StaticsServer + "/Statics/JavaScripts/Dipan.SanGuo.NpcCity.js", true);
                                }
                                break;
                            case 71:
                            case 72:
                            case 73://玩家城池
                                {
                                    var Loader = new Dipan.SanGuo.Common.Loader();
        
                                    Loader.onsuccess = function()
                                    {
                                        var array = aPlace[3].toString().match(/\d/gim);
                                        Dipan.SanGuo.CityTents.citytents(array[1],aPlace[2]);
                                    }
                                    
                                    Loader.js(Dipan.SanGuo.Common.StaticsServer + "/Statics/JavaScripts/Dipan.SanGuo.CityTents.js", true);
                                }
                                break;
                        }
                    }
                }
                else
                {
                    //拖动地图结束后获取新的数据并重新生成地图显示层

                    //移动距离
                    var nx = p.style.left.substring(0,p.style.left.indexOf('px'));
                    var ny = p.style.top.substring(0,p.style.top.indexOf('px'));
                    var NewCenterMapId = Dipan.SanGuo.Map.NewCenterMapId(nx,ny);
                    
                    Dipan.SanGuo.Map.Query(NewCenterMapId, true);
                }
            }
            
            o.onmouseleave = function()
            {
                if(o.releaseCapture) o.releaseCapture(); else if(window.captureEvents) window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); d.onmousemove = null; d.onmouseup = null; d.ondragstart = null; d.onselectstart = null; d.onselect = null;
                o.onmousemove = null;
                o.onmouseup = null;
                o.onmouseleave = null;
                o.style.cursor = "default";
                var temp = (typeof a.target != "undefined")?a.target:a.srcElement;
                
                //拖动地图结束后获取新的数据并重新生成地图显示层

                //移动距离
                var nx = p.style.left.substring(0,p.style.left.indexOf('px'));
                var ny = p.style.top.substring(0,p.style.top.indexOf('px'));
                var NewCenterMapId = Dipan.SanGuo.Map.NewCenterMapId(nx,ny);
                
                Dipan.SanGuo.Map.Query(NewCenterMapId, true);
            }
        }
	},
	
	/**
     * 显示营寨浮层
     * @param {index} 营寨索引
     * @param {mapid} 地图编号
     */
	ShowTents: function(index,mapid)
	{
	    var Loader = new Dipan.SanGuo.Common.Loader();
        
        Loader.onsuccess = function()
        {
            Dipan.SanGuo.ShowTents.showtents(index,mapid);
        }
        
        Loader.js(Dipan.SanGuo.Common.StaticsServer + "/Statics/JavaScripts/Dipan.SanGuo.ShowTents.js", true);
	},
	
	/**
     * 显示地图任务浮层
     * @param {index} 任务索引
     * @param {mapid} 地图编号
     */
	ShowNpcTent: function(index,mapid)
	{
	    var Loader = new Dipan.SanGuo.Common.Loader();
        
        Loader.onsuccess = function()
        {
            Dipan.SanGuo.ShowNpcTent.shownpctent(index,mapid);
        }
        
        Loader.js(Dipan.SanGuo.Common.StaticsServer + "/Statics/JavaScripts/Dipan.SanGuo.ShowNpcTent.js", true);
	},
	
	/**
     * 获取营寨信息
     * @param {index} 营寨索引
     * @param {mapid} 地图编号
     */
	GetTentInfo: function(index, mapid)
	{
	    return Dipan.SanGuo.Map.MapData.tents[index][1] + " ("+Dipan.SanGuo.Common.MapIdToPos(mapid)+")<br />主公："+Dipan.SanGuo.Map.Users[Dipan.SanGuo.Map.MapData.tents[index][2]][1]+"<br />联盟：" + Dipan.SanGuo.Map.Users[Dipan.SanGuo.Map.MapData.tents[index][2]][3];
	},
	
	/**
     * 获取地图任务信息
     * @param {index} 营寨索引
     * @param {mapid} 地图编号
     */
	GetNpcTentInfo: function(index, mapid)
	{
	    return Dipan.SanGuo.Map.Config[Dipan.SanGuo.Map.MapData.npc_tent[index][1]-1][0] + "部队 ("+Dipan.SanGuo.Common.MapIdToPos(mapid)+")";
	},
	
	Config:
	[
	    ["倭国","倭国是我朝东边一岛国，常从海上侵犯沿海百姓，烧杀抢掠，无恶不作。近来更有一些气焰嚣张的倭寇部队一直深入我朝境内。朝廷发现倭寇对本国的图腾十分崇拜，如能在边境地区多多树立图腾就能令其不敢进犯，平息一场征战！倭国的士兵往往将图腾随军携带，只要能消灭他们就有可能获得这些图腾！"],
	    ["鲜卑","北部的鲜卑国本与我朝相安多年，然近些年来势力逐渐壮大，一直对我朝虎视眈眈，时常在边境进行劫掠，使得百姓饱受侵略之苦，近来更有一些气焰嚣张的部队一直深入我朝境内。朝廷发现鲜卑一族对本族的图腾十分崇拜，如能在边境地区多多树立图腾就能令其不敢进犯，平息一场征战！鲜卑族的士兵往往将图腾随军携带，只要能消灭他们就有可能获得这些图腾！"],
	    ["乌桓","乌桓一族本与我朝相安多年，然近些年来势力逐渐壮大，一直对我朝虎视眈眈，时常在边境进行劫掠，使得百姓饱受侵略之苦，近来更有一些气焰嚣张的部队一直深入我朝境内。朝廷发现乌桓一族对本族的图腾十分崇拜，如能在边境地区多多树立图腾就能令其不敢进犯，平息一场征战！乌桓的士兵往往将图腾随军携带，只要能消灭他们就有可能获得这些图腾！"],
	    ["山越","山越是分布在我朝南部山岳地区的异族，本与我朝相安多年，然近些年来锻造武器，组建军队，势力逐渐壮大，一直对我朝虎视眈眈，时常在边境进行劫掠，使得百姓饱受侵略之苦，近来更有一些气焰嚣张的部队一直深入我朝境内。朝廷发现山越一族对本族的图腾十分崇拜，如能在边境地区多多树立图腾就能令其不敢进犯，平息一场征战！山越族的士兵往往将图腾随军携带，只要能消灭他们就有可能获得这些图腾！"],
	    ["羌氐","西部的羌氐一族本与我朝相安多年，然近些年来势力逐渐壮大，一直对我朝虎视眈眈，时常在边境进行劫掠，使得百姓饱受侵略之苦，近来更有一些气焰嚣张的部队一直深入我朝境内。朝廷发现羌氐一族对本族的图腾十分崇拜，如能在边境地区多多树立图腾就能令其不敢进犯，平息一场征战！羌氐族的士兵往往将图腾随军携带，只要能消灭他们就有可能获得这些图腾！"],
	    ["南蛮","南蛮本与我朝相安多年，然近些年来势力逐渐壮大，一直对我朝虎视眈眈，时常在边境进行劫掠，使得百姓饱受侵略之苦，近来更有一些气焰嚣张以南王孟获为首的部队一直深入我朝境内。朝廷发现南蛮一族对本族的图腾十分崇拜，如能在边境地区多多树立图腾就能令其不敢进犯，平息一场征战！南蛮的士兵往往将图腾随军携带，只要能消灭他们就有可能获得这些图腾！ "],
	    ["匈奴","匈奴是各部族势力中实力最强的一只部队，一直对我朝虎视眈眈，时常在边境进行劫掠，使得百姓饱受侵略之苦，近来更有一些气焰嚣张的部队一直深入我朝境内。朝廷发现匈奴一族对本族的图腾十分崇拜，如能在边境地区多多树立图腾就能令其不敢进犯，平息一场征战！匈奴的士兵往往将图腾随军携带，只要能消灭他们就有可能获得这些图腾！"]
	],
	
	/**
     * 根据移动的偏移量计算新的中心点坐标
     * @param {mx} 横向移动值
     * @param {my} 纵向移动值
     */
	NewCenterMapId: function(mx, my)
	{
	    //原始地图的中心点坐标
	    var aOldPos = Dipan.SanGuo.Common.MapIdToPos(Dipan.SanGuo.Map.CenterMapId).split(',');

		// 得到移动之后的中心点坐标
	    var nMX = Math.round(Math.abs(mx) / 90);
	    var nMY = Math.round(Math.abs(my) / 72);

	    if (mx < 0) nMX = 0 - nMX;
	    if (my < 0) nMY = 0 - nMY;

	    var nNowPosX = 0, nNowPosY = 0;
		nNowPosX = 0 - nMX - nMY;
		nNowPosY = 0 - nMX + nMY;
		nNowPosX = aOldPos[0] * 1 + nNowPosX;
		nNowPosY = aOldPos[1] * 1 + nNowPosY;
        
        //解决坐标越界
        if (nNowPosX > 656)  nNowPosX = 656
        if (nNowPosX < -656) nNowPosX = -656
        if (nNowPosY > 656)  nNowPosY = 656
        if (nNowPosY < -656) nNowPosY = -656

        //返回新的中心点

        return Dipan.SanGuo.Common.MapPosToId(nNowPosX, nNowPosY);
	},
	
	/**
     * 获取地块信息小浮层
     * @param {MapId} 地块编号
     * @param {type} 地块类型
     */
	GetPlaceInfo: function(MapId, type)
    {
        var title = "";
        var desc = "";
        
        if (Dipan.SanGuo.Map.copyright)
        {
            if (MapId == "1103754") {return "powered by sheepchang ("+Dipan.SanGuo.Common.MapIdToPos(MapId)+")<br />sheepchang@163.com";}
            if (MapId == "74405") {return "powered by 8599 ("+Dipan.SanGuo.Common.MapIdToPos(MapId)+")<br />8599@live.com";}
        }

        if  (type == 1)
            return "空地("+Dipan.SanGuo.Common.MapIdToPos(MapId)+")<br />空地上可以建立新城或营寨。";
        else if (type > 10 && type < 60)
        {
            var array = type.toString().match(/\d/gim);
	        
	        switch (array[0]*1)
	        {
	            case 1 :
	                {
	                    title = "良田";
	                    other = "良田出产粮食。<br />";
	                }
	                break;
	            case 2 :
	                {
	                    title = "湖泊";
	                    other = "湖泊出产粮食。<br />";
	                }
	                break;
	            case 3 :
	                {
	                    title = "树林";
	                    other = "树林出产木材。<br />";
	                }
	                break;
	            case 4 :
	                {
	                    title = "山地";
	                    other = "山地出产石料。<br />";
	                }
	                break;
	            case 5 :
	                {
	                    title = "矿脉";
	                    other = "矿脉出产铁矿。<br />";
	                }
	                break;
	        }
	        
	         if  (array[1]*1 == 1)
                desc = "1级绿洲是开放的。<br />";
             else
                desc = ""+array[1]+"级绿洲需要"+array[1]+"级以上开采权才能开发。";
	        
	        return ""+array[1]+"×"+array[1]+""+title+"("+Dipan.SanGuo.Common.MapIdToPos(MapId)+")<br />" + other + desc;
        }
        else if (type > 61 && type < 66)
        {
            var array = type.toString().match(/\d/gim);
	        switch (array[1]*1)
	        {
	            case 2 :
	                {
	                    title = "县城";
	                }
	                break;
	            case 3 :
	                {
	                    title = "郡城";
	                }
	                break;
	            case 4 :
	                {
	                    title = "州城";
	                }
	                break;
	            case 5 :
	                {
	                    title = "王城";
	                }
	                break;
	        }
	        
	        var npc = Dipan.SanGuo.Map.Npc[Dipan.SanGuo.Map.Infos[MapId][5]][3];
	        
	        if (npc == 0)//未被占领
	            return ""+title+" ("+Dipan.SanGuo.Common.MapIdToPos(MapId)+")<br />未被占领的"+title+"";
	        else
	            return ""+title+" ("+Dipan.SanGuo.Common.MapIdToPos(MapId)+")<br />联盟："+Dipan.SanGuo.Map.Npc[Dipan.SanGuo.Map.Infos[MapId][5]][4]+" ";
        }
        else if (type > 70 && type < 74)
        {
            var array = type.toString().match(/\d/gim);
	        
	        return ""+Dipan.SanGuo.Map.Citys[Dipan.SanGuo.Map.Infos[MapId][5]][1]+" ("+Dipan.SanGuo.Common.MapIdToPos(MapId)+") <br />主公："+Dipan.SanGuo.Map.Users[Dipan.SanGuo.Map.Citys[Dipan.SanGuo.Map.Infos[MapId][5]][3]][1]+" <br />联盟："+Dipan.SanGuo.Map.Users[Dipan.SanGuo.Map.Citys[Dipan.SanGuo.Map.Infos[MapId][5]][3]][3]+" ";
        }
    },
    
    /**
     * 显示信息浮层
     * @param {index} 索引编号
     * @param {flag} 标志是营寨还是空地
     */
    ShowItemDetail: function(index, flag)
    {
        try
        {
            var data;
            if (flag == 1)//地块信息
            {
                data = {flag:1,infos:[Dipan.SanGuo.Map.MapData.infos[index][0],Dipan.SanGuo.Map.MapData.infos[index][1]]};
            }
            else if (flag == 2)//营寨信息
            {
                data = {flag:2,infos:[index,Dipan.SanGuo.Map.MapData.tents[index][3]]};
            }
            else if (flag == 3)//地图任务信息
            {
                data = {flag:3,infos:[index,Dipan.SanGuo.Map.MapData.npc_tent[index][2]]};
            }
            
            Dipan.SanGuo.Common.FixData(Dipan.SanGuo.Map.Template.DivItemDetail, "DivItemDetail", data, true);
        }
        catch (e)
        {
            //alert(e.message);
        }
        
        var o = $("DivItemDetail");
        if (o)
        {
            o.style.cssText = "position:absolute; z-index:1103754";
            var cw = Math.max(document.body.clientWidth, document.documentElement.clientWidth);
            var st = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
            evt = (window.event) ? window.event : Dipan.SanGuo.Map.ShowItemDetail.caller.arguments[0];
            o.style.left = (evt.clientX + 260 > cw) ? (evt.clientX - 260) + "px" : (evt.clientX - 2) + "px";    
            o.style.top = (evt.clientY + 20 + st) + "px";
            new Effect.Opacity('DivItemDetail', {duration:0.0, from:0.7, to:0.7});
        }
    },
    
    /**
     * 隐藏信息浮层
     */
    HideItemDetail: function()
    {
	    var o = $("DivItemDetail");
	    if (o)
        {
	        o.style.display = "none";
	    }
    },
    
    /**
     * 获取页面Flash
     * @param {moviename} Flash名称
     */
    Movie: function(moviename)
    {
        if (!document.attachEvent) 
        {
            return $("e" + moviename);
        }
        else 
        {
            return $("o" + moviename);
        }
    },
    
    /**
     * 生成页面Flash
     */
    WriteNavigation: function()
	{
	    Dipan.SanGuo.Map.nComId = (Math.floor(((Dipan.SanGuo.Map.CenterMapId - 1) % ( 1313 )) / 101)) + 1 + 13 * (Math.floor((Math.floor((Dipan.SanGuo.Map.CenterMapId - 1) / (1313))) / 101));
	    var axy = Dipan.SanGuo.Common.MapIdToPos(Dipan.SanGuo.Map.CenterMapId).split(',');
        
        var nTop = Dipan.SanGuo.Common.GetCookie("navigation");
        
        var nav = $("navigation");
        var mopen = 1;
        
        if (nTop == "")
        {
            nav.style.cssText = "z-index:110;top:35px";
            mopen = 1;
        }
        else
        {
            nav.style.cssText = "z-index:110;top:"+nTop+"px";
            if (nTop == "-270")
                mopen = 0;
            else
                mopen = 1;
        }
        
        var strRe = "";
        strRe += "<object id=\"oCom\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"350px\" height=\"328px\">";
        strRe += "<param name=\"movie\" value=\"/Statics/Images/flashMap.swf?thex="+axy[0]+"&they="+axy[1]+"&mopen="+mopen+"&cur_url="+escape(Dipan.SanGuo.Common.NavPic)+"\" width=\"350px\" height=\"328px\"/>";
        strRe += "<param name=\"quality\" value=\"high\" />";
        strRe += "<param name=\"wmode\" value=\"transparent\" />";
        strRe += "<param name=\"allowScriptAccess\" value=\"always\" />";
        strRe += "<embed id=\"eCom\" src=\"/Statics/Images/flashMap.swf?thex="+axy[0]+"&they="+axy[1]+"&mopen="+mopen+"&cur_url="+escape(Dipan.SanGuo.Common.NavPic)+"\" wmode=\"transparent\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"350px\" height=\"328px\"></embed>";
        strRe += "</object>";
        
        nav.innerHTML = strRe;
        
        //new Effect.Opacity('navigation', {duration:0.0, from:0.7, to:0.7});
        
        //Dipan.SanGuo.Map.NavigationShowPos();
	},
	
	nComId:null,
	
	/**
     * 初始导航
     */
	NavigationShowPos: function()
	{
	    Dipan.SanGuo.Map.nComId = (Math.floor(((Dipan.SanGuo.Map.CenterMapId - 1) % ( 1313 )) / 101)) + 1 + 13 * (Math.floor((Math.floor((Dipan.SanGuo.Map.CenterMapId - 1) / (1313))) / 101));
	    var axy = Dipan.SanGuo.Common.MapIdToPos(Dipan.SanGuo.Map.CenterMapId).split(',');
	    try
	    {
	        window.setTimeout("Dipan.SanGuo.Map.Movie('Com').jsCallFlash("+Dipan.SanGuo.Map.nComId+","+axy[0]+","+axy[1]+")", 500);
	    }
	    catch(e)
	    {
	        Dipan.SanGuo.Map.Movie('Com').jsCallFlash(nComId,axy[0],axy[1])
	    }
	},
	
	/**
     * 点击Flash切换地图
     * @param {x} X坐标
     * @param {y} X坐标
     */
	ClickNavigation: function(x,y)
	{
	    Dipan.SanGuo.Map.CenterMapId = Dipan.SanGuo.Common.MapPosToId(Math.floor(x),Math.floor(y));
	    Dipan.SanGuo.Map.Query(Dipan.SanGuo.Map.CenterMapId, false);
	},
	
	/**
     * 收回导航图
     * @param {nI} nI
     */
	CallBackNavigation: function(nI)
	{
        $("navigation").style.top = 40 * 1 - nI * 1 + "px";
	    if (nI < 306)
	    {
	        window.setTimeout("Dipan.SanGuo.Map.CallBackNavigation('" + (nI * 1 + 10 * 1) + "')", 10);
	    }
	},
	
	/**
     * 显示导航图
     * @param {nI} nI
     */
	ShowNavigation: function(nI)
	{
	    $("navigation").style.top = 40 * 1 - nI * 1 + "px";
	    if (nI >= 10)
	    {
	        window.setTimeout("Dipan.SanGuo.Map.ShowNavigation('" + (nI * 1 - 10 * 1) + "')", 10);
	    }
	},
	
	/**
     * 显示或收回导航图
     */
	ShowOrCallBack: function()
	{
	    var nTop = $("navigation").style.top + "";
	    if (nTop == "")
	    {
	        this.CallBackNavigation(0);
	        Dipan.SanGuo.Common.SetCookie("navigation", "-270");
	    }
	    else if (nTop.substring(0, nTop.length - 2) * 1 > 0)
	    {
	        this.CallBackNavigation(0);
	        Dipan.SanGuo.Common.SetCookie("navigation", "-270");
	    }
	    else
	    {
	        this.ShowNavigation(306);
	        Dipan.SanGuo.Common.SetCookie("navigation", "35");
	    }
	},
	
	/**
     * 显示发送消息

     * @param {uname} 接收人
    yn为0不是群发
     */
	ShowMessage: function(uname,yn)
	{
	    if(!yn)yn=0;
	    var Loader = new Dipan.SanGuo.Common.Loader();
        Loader.onsuccess = function()
        {
            Dipan.SanGuo.Common.FixData(Dipan.SanGuo.Map.Template.ShowMessage, "_msg", {uname:uname,yn:yn}, false);
            new Draggable("drag_msg", true);
        }
		Loader.js(Dipan.SanGuo.Common.StaticsServer + "/Statics/JavaScripts/message_list.js",true);
	},
	
	/**
     * 发送消息
     */
	SendMessage: function()
	{
        $('title').value=$('title').value.replace(/(^\s*)|(\s*$)/g,  "");
	    if($('name').value=='')
	    {
		    alert('请输入收件人。');	
		    $('name').focus();
	    }
	    else if(checklen($('name').value,32))
	    {
		    alert('收件人输入错误，请重新输入。');
		    $('name').focus();		
	    }	
	    else if($('title').value=='')
	    {
		    alert('请输入标题。');	
		    $('title').focus();
	    }	
	    else if(checklen($('title').value,120))
	    {
		    alert('标题不能超过120个字符或60个汉字，请重新输入。');
		    $('title').focus();	
	    }
	    else if($('content').value=='')
	    {
		    alert('请输入内容。');	
		    $('content').focus();
	    }	
	    else if(checklen($('content').value,1000))
	    {
		    alert('内容不能超过1000个字符或500个汉字，请重新输入。');
		    $('content').focus();	
	    }	
	    else
	    {
	        var msg = $F('content').replace(/(^\s*)|(\s*$)/g, "");			
            msg = msg.replace(/([　])/g,"");
            msg = Dipan.SanGuo.Common.ReplaceBadString(msg);
            
	        var title1 = $F('title').replace(/(^\s*)|(\s*$)/g, "");			
            title1 = title1.replace(/([　])/g,"");
            title1 = Dipan.SanGuo.Common.ReplaceBadString(title1);            
            
            var RemoteData = new Dipan.SanGuo.Common.RemoteData()
            RemoteData.Post("/GateWay/OPT.ashx?id=51","name=" + encodeURIComponent($F('name')) + "&title=" + encodeURIComponent(title1)+ "&content=" + encodeURIComponent(msg));
            RemoteData.onComplete = function(resp)
            {
                var JsonData = eval('(' + resp + ')');
                if (JsonData.ret * 1 == 0)
                {
                    alert("发送消息成功");
                    Dipan.SanGuo.Common.CloseDialog("_msg");
                }
                else
                {
                    //返回不成功后到统一方法处理错误信息
                    Dipan.SanGuo.Common.ResultInfo(JsonData.ret);
                }
            }
	    }
	},
	
	/**
     * 地图跳转
     * @param {map_id} 地图编号
     */
	GoToMap: function(map_id)
    {
        //注释掉，因为在聚合页跳转时会出问题
        //if (window.location.href.indexOf("/map") == -1)
        //{/
            Dipan.SanGuo.Common.SetCookie("mid", map_id, {path:"/"});
            window.location.href = "/map/" + map_id;
        //}
        //else
        //{
          //  Dipan.SanGuo.Map.Query(map_id, true);
          //  Dipan.SanGuo.Common.CloseDialog('_float');
        //}
    },
    /**
     * 地图跳转
     * @param {x,y} 地图编号
     */
    GoToMapXY: function(xx,yy)
    {
        var mapid=Dipan.SanGuo.Common.MapPosToId(xx,yy);
        this.GoToMap(mapid);
    },
    
    goHome: function()
    {
        var mid = Dipan.SanGuo.Common.GetCookie("mid");
        this.GoToMap(mid);
    },
    
    GetStateStat: function(state_id)
    {
        var arry = [];
        for (var i = 0; i < arr_zhouinfo.length; i++)
		{		
			if (arr_zhouinfo[i].id == state_id)
			{
				arry[0] = arr_zhouinfo[i].users;
				arry[1] = Math.round((arr_zhouinfo[i].users/arr_zhouinfo[i].max_users)*100);
				
				break;
			}
		}
		
		//alert(arry[0]);
		return arry;
    },
    
    zhou_obj: function(_id,_name,_users,_citys,_max_users,_isok)
    {
		this.id  = _id		
		this.name  = _name;
		this.users  = _users;
		this.citys  = _citys;
		this.max_users  = _max_users;		
		this.isok  = _isok;				
    }
};